#include "../../Graphics/Presentation.h"
#include "./Tile.h"

namespace GameLogic {
namespace Level {

Tile* Tile::EMPTY = new Tile();

Tile::Tile(
	Ogre::SceneNode* scene_node,
	bool enterable_left,
	bool enterable_right,
	bool enterable_top,
	bool enterable_bottom
):
	size_( 1.0f ),
	x1_( 0.0f ), y1_( 0.0f ), x2_( size_ ), y2_( size_ ),
	enterable_( enterable_left || enterable_right || enterable_top || enterable_bottom ),
	enterable_left_( enterable_left ), enterable_right_( enterable_right ),
	enterable_top_( enterable_top ), enterable_bottom_( enterable_bottom ),
	scene_node_( scene_node )
{}

void Tile::onInsert( int x, int y, float size ) {
	size_ = size;
	float disp = x * size;
	x1_ += disp;
	x2_ += disp;
	disp = y * size;
	y1_ += disp;
	y2_ += disp;
	//Graphics::Presentation::getInstance().
	scene_node_->translate(
			Graphics::Presentation::toOgreCoords( x1_ + 0.5f * size ),
			Graphics::Presentation::toOgreCoords( -1.0f ),
			Graphics::Presentation::toOgreCoords( y1_ + 0.5f * size )
	);
}

} //namespace Level
} //namespace GameLogic
